global root "/Volumes/Workgroup/Lab/Lab-heimb/Montenovo/Volunteering Paper/Data"
global results "$root/07_results/RR/main"
global dictionaries "$root/Dictionaries"

cd "$dictionaries"
capture log close
log using preliminary_regressions, replace

cd "$root"
use appended_analytic_010305111719, clear 

//drop if education_head==.
//count if education_wife==. & sequence_num==2

//bysort year: sum taxprice

foreach var of varlist whether_volunteer_person taxprice post_tax_income  age sex  married black native_amer asian other hispanic HS some_college college_grad college_plus children religion rural {
	count if `var'==.
}
/*
  1,181 // whether_volunteer_person
  1,210 // TAXPRICE
  0 // AGE
  211 // SEX
  0
  0
  0
  0
  0
  0
  3,225 // HISPANIC
  2,716 // EDUC
  2,716
  2,716
  2,716
  0


*/

// count if hours_volunteer_person==.
// 13,758

// check educ by person

foreach var of varlist sex black native_amer asian other hispanic {
bysort unique_id_crossys: egen sd_`var'=sd(`var')
tab sd_`var'
drop sd_`var'
}

drop if year==2010

*intensive, no fe
eststo intensive_margin: reghdfe hours_volunteer_person  taxprice post_tax_income hourly_wage_aftertax full_time age sex  married black native_amer asian other hispanic HS some_college college_grad college_plus children religion rural, noabsorb vce(cluster state)
gen sample=e(sample)
bysort unique_id_crossys: gen nvals=_n==1
count if nvals==1 & sample==1
drop sample nvals

*intensive, yr fe
eststo intensive_margin_yrfe: reghdfe hours_volunteer_person taxprice post_tax_income hourly_wage_aftertax full_time age sex  married black native_amer asian other hispanic HS some_college college_grad college_plus children religion rural, absorb(year) vce(cluster state)
gen sample=e(sample)
bysort unique_id_crossys: gen nvals=_n==1
count if nvals==1 & sample==1
drop sample nvals
*intensive, yr state fe
eststo intensive_margin_stfe: reghdfe hours_volunteer_person taxprice post_tax_income hourly_wage_aftertax full_time age sex  married black native_amer asian other hispanic HS some_college college_grad college_plus children religion rural, absorb(year state) vce(cluster state)
gen sample=e(sample)
bysort unique_id_crossys: gen nvals=_n==1
count if nvals==1 & sample==1
drop sample nvals
*intensive, year state individual fe
eststo intensive_margin_fe: reghdfe hours_volunteer_person taxprice post_tax_income hourly_wage_aftertax full_time age sex  married black native_amer asian other hispanic HS some_college college_grad college_plus children religion rural, absorb(year state unique_id_crossys) vce(cluster state)
gen sample=e(sample)
bysort unique_id_crossys: gen nvals=_n==1
count if nvals==1 & sample==1
drop sample nvals

cd "$results"

		 esttab intensive_margin intensive_margin_yrfe intensive_margin_stfe intensive_margin_fe using "preliminary_regress_intensive_with0s.rtf", se star(* 0.10 ** 0.05 *** 0.01) replace se(a4) b(a3) title("Intensive Margin") addnotes("Outcome Variable: Total hours the person volunteered"  "Col 1: No FE" "Col 2: Year FE" "Col 3: Year FE and State FE" "Col 4: Year, State, Individual FE") modelwidth(12) label cells(b(star fmt(3)) se(par fmt(3)))
	 
//////////////////////////////////////////////////////////////////////////
	 cd "$dictionaries"
log close	 


	 
	